import { defineStore } from 'pinia'

export const useVueApisCollapseStore = defineStore('vueApisCollapse', {
    state: () => ({
        activeNames: [],
        collapseAll: false
    }),
    getters: {
        getActiveNames() {
            return this.activeNames
        },
        getCollapseAllState() {
            return this.collapseAll
        },
    },
    actions: {
        setActiveNames(list) {
            this.activeNames = list
        },
        setCollapseAllState(boolean) {
            this.collapseAll = boolean
        },
    },
    // 开启数据缓存,pinia-plugin-persist插件效果
    persist: {
        enabled: true,
        strategies: [
            {
                key: 'vueApisCollapse', // 存储的 key 值，默认为 storeId
                storage: localStorage, // 存储的位置，默认为 sessionStorage
                paths: ['activeNames', 'collapseAll'], // 需要存储的 state 状态，默认存储所有的状态
            }
        ]
    }
})